package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.vo.OrderSearchVo;
import com.ruoyi.system.domain.vo.OrderVo;
import com.ruoyi.system.domain.vo.PCLoginVo;
import com.ruoyi.system.domain.vo.PcLoginSearchVo;
import com.ruoyi.system.dto.OrderDTO;
import com.ruoyi.system.service.IOrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/pay")
public class PayController extends BaseController {
    @Autowired
    private IOrderService orderService;
    /**
     * 订单支付记录新增或修改
     */
    @ApiOperation(value = "订单支付记录新增或修改")
    @PostMapping(value = "/createOrder")
    public AjaxResult addOrUpdate(@RequestBody OrderVo orderVo)
    {
        return success(orderService.addOrUpdate(orderVo));
    }


    /*
   购买订单记录
   */
    @GetMapping("/orderList")
    @Anonymous
    public TableDataInfo list(OrderSearchVo searchVo)
    {
        startPage();
        List<OrderDTO> list = orderService.getList(searchVo);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(200);
        rspData.setMsg("查询成功");
        rspData.setRows(list);
        rspData.setTotal(orderService.getListCount(searchVo));
        return rspData;
    }
}
